//
//  CertificationPhotoCell.m
//  CoachsBook
//
//  Created by huiyong li on 2022/8/18.
//

#import "CertificationPhotoCell.h"


@interface CertificationPhotoCell ()
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIView *BJView1;
@property (nonatomic, strong) UILabel *nameLabel1;
@property (nonatomic, strong) UILabel *contentLabel1;
@property (nonatomic, strong) UIView *BJView2;
@property (nonatomic, strong) UILabel *nameLabel2;
@property (nonatomic, strong) UILabel *contentLabel2;
@property (nonatomic, strong) UIView *BJView3;
@property (nonatomic, strong) UILabel *nameLabel3;
@property (nonatomic, strong) UILabel *contentLabel3;
@property (nonatomic, strong) UIView *BJView4;
@property (nonatomic, strong) UILabel *nameLabel4;
@property (nonatomic, strong) UILabel *contentLabel4;



@end


@implementation CertificationPhotoCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier])
    {
        [self setViews];
        self.contentView.backgroundColor = rgba(255, 255, 255, 1);
    }
    return self;
}

- (void)setViews
{
    
    
    
    UIView *HeaderV = [[UIView alloc]initWithFrame:CGRectMake(0, 0, APPwidth, 55)];
    HeaderV.backgroundColor = [UIColor whiteColor];
    
    UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, 0, APPwidth, 10)];
    line.backgroundColor = rgba(245, 245, 250, 1);
    [HeaderV addSubview:line];
    
    UIView *myDataLineV = [[UIView alloc]initWithFrame:CGRectMake(15, 25, 3, 15)];
    myDataLineV.backgroundColor = rgba(22, 120, 255, 1);
    myDataLineV.layer.cornerRadius = 2;
    [HeaderV addSubview:myDataLineV];
    self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(myDataLineV.frame)+5, 25, 150, 15)];
    self.titleLabel.text = @"上传证件照";
    self.titleLabel.textColor = [UIColor blackColor];
    self.titleLabel.textAlignment = 0;
    self.titleLabel.font = kPingFangSemibold(16);
    [HeaderV addSubview:self.titleLabel];
    
    
    self.BJView1 = [[UIView alloc]initWithFrame:CGRectMake(15, CGRectGetMaxY(HeaderV.frame)+5, APPwidth - 30, 48+((APPwidth-30)/2-30)*88/135)];
    self.BJView1.backgroundColor = rgba(245, 245, 250, 1);
    self.BJView2 = [[UIView alloc]initWithFrame:CGRectMake(15, CGRectGetMaxY(self.BJView1.frame)+15, APPwidth - 30, 48+((APPwidth-30)/2-30)*88/135)];
    self.BJView2.backgroundColor = rgba(245, 245, 250, 1);
    self.BJView3 = [[UIView alloc]initWithFrame:CGRectMake(15, CGRectGetMaxY(self.BJView2.frame)+15, APPwidth - 30, 48+((APPwidth-30)/2-30)*88/135)];
    self.BJView3.backgroundColor = rgba(245, 245, 250, 1);
    self.BJView4 = [[UIView alloc]initWithFrame:CGRectMake(15, CGRectGetMaxY(self.BJView3.frame)+15, APPwidth - 30, 48+((APPwidth-30)/2-30)*88/135)];
    self.BJView4.backgroundColor = rgba(245, 245, 250, 1);
    
    
    self.nameLabel1 = [[UILabel alloc]initWithFrame:CGRectMake(0, (self.BJView1.height-60)/2, (APPwidth-30)/2, 30)];
    self.nameLabel1.font = kPingFangRegular(16);
    self.nameLabel1.textColor = rgba(51, 51, 51, 1);
    self.nameLabel1.textAlignment = NSTextAlignmentCenter;
    self.nameLabel1.text = @"国徽面";
    
    self.contentLabel1 = [[UILabel alloc]initWithFrame:CGRectMake(0, (self.BJView1.height-60)/2+30, (APPwidth-30)/2, 30)];
    self.contentLabel1.font = kPingFangRegular(12);
    self.contentLabel1.textColor = rgba(153, 153, 153, 1);
    self.contentLabel1.textAlignment = NSTextAlignmentCenter;
    self.contentLabel1.text = @"上传身份证国徽面";
    
    self.photoImage1 = [[UIImageView alloc]initWithFrame:CGRectMake((APPwidth-30)/2, 24, (APPwidth-30)/2-30, ((APPwidth-30)/2-30)*88/135)];
    self.photoImage1.userInteractionEnabled = YES;
    //添加虚线边框
    CAShapeLayer*border = [CAShapeLayer layer];
    border.strokeColor=rgba(153, 153, 153, 1).CGColor;
    border.fillColor= [UIColor clearColor].CGColor;
    border.path= [UIBezierPath bezierPathWithRoundedRect:self.photoImage1.bounds cornerRadius:0].CGPath;
    border.frame= self.photoImage1.bounds;
    border.lineWidth=1.0f;
    border.lineDashPattern=@[@4,@2];
    [self.photoImage1.layer addSublayer:border];
    
    [self.BJView1 addSubview:self.nameLabel1];
    [self.BJView1 addSubview:self.contentLabel1];
    [self.BJView1 addSubview:self.photoImage1];
    

    
    self.nameLabel2 = [[UILabel alloc]initWithFrame:CGRectMake(0, (self.BJView2.height-60)/2, (APPwidth-30)/2, 30)];
    self.nameLabel2.font = kPingFangRegular(16);
    self.nameLabel2.textColor = rgba(51, 51, 51, 1);
    self.nameLabel2.textAlignment = NSTextAlignmentCenter;
    self.nameLabel2.text = @"驾驶证正面";
    
    self.contentLabel2 = [[UILabel alloc]initWithFrame:CGRectMake(0, (self.BJView2.height-60)/2+30, (APPwidth-30)/2, 30)];
    self.contentLabel2.font = kPingFangRegular(12);
    self.contentLabel2.textColor = rgba(153, 153, 153, 1);
    self.contentLabel2.textAlignment = NSTextAlignmentCenter;
    self.contentLabel2.text = @"上传驾驶证正面";
    
    self.photoImage2 = [[UIImageView alloc]initWithFrame:CGRectMake((APPwidth-30)/2, 24, (APPwidth-30)/2-30, ((APPwidth-30)/2-30)*88/135)];
    self.photoImage2.userInteractionEnabled = YES;
    //添加虚线边框
    CAShapeLayer*border2 = [CAShapeLayer layer];
    border2.strokeColor=rgba(153, 153, 153, 1).CGColor;
    border2.fillColor= [UIColor clearColor].CGColor;
    border2.path= [UIBezierPath bezierPathWithRoundedRect:self.photoImage2.bounds cornerRadius:0].CGPath;
    border2.frame= self.photoImage2.bounds;
    border2.lineWidth=1.0f;
    border2.lineDashPattern=@[@4,@2];
    [self.photoImage2.layer addSublayer:border2];
    
    [self.BJView2 addSubview:self.nameLabel2];
    [self.BJView2 addSubview:self.contentLabel2];
    [self.BJView2 addSubview:self.photoImage2];
    
    
    
    self.nameLabel3 = [[UILabel alloc]initWithFrame:CGRectMake(0, (self.BJView3.height-60)/2, (APPwidth-30)/2, 30)];
    self.nameLabel3.font = kPingFangRegular(16);
    self.nameLabel3.textColor = rgba(51, 51, 51, 1);
    self.nameLabel3.textAlignment = NSTextAlignmentCenter;
    self.nameLabel3.text = @"个人照片";
    
    self.contentLabel3 = [[UILabel alloc]initWithFrame:CGRectMake(0, (self.BJView3.height-60)/2+30, (APPwidth-30)/2, 30)];
    self.contentLabel3.font = kPingFangRegular(12);
    self.contentLabel3.textColor = rgba(153, 153, 153, 1);
    self.contentLabel3.textAlignment = NSTextAlignmentCenter;
    self.contentLabel3.text = @"上传清晰个人照片";
    
    self.photoImage3 = [[UIImageView alloc]initWithFrame:CGRectMake((APPwidth-30)/2, 24, (APPwidth-30)/2-30, ((APPwidth-30)/2-30)*88/135)];
    self.photoImage3.userInteractionEnabled = YES;
    //添加虚线边框
    CAShapeLayer*border3 = [CAShapeLayer layer];
    border3.strokeColor=rgba(153, 153, 153, 1).CGColor;
    border3.fillColor= [UIColor clearColor].CGColor;
    border3.path= [UIBezierPath bezierPathWithRoundedRect:self.photoImage3.bounds cornerRadius:0].CGPath;
    border3.frame= self.photoImage3.bounds;
    border3.lineWidth=1.0f;
    border3.lineDashPattern=@[@4,@2];
    [self.photoImage3.layer addSublayer:border3];
    
    [self.BJView3 addSubview:self.nameLabel3];
    [self.BJView3 addSubview:self.contentLabel3];
    [self.BJView3 addSubview:self.photoImage3];
    
    
    
    self.nameLabel4 = [[UILabel alloc]initWithFrame:CGRectMake(0, (self.BJView4.height-60)/2, (APPwidth-30)/2, 30)];
    self.nameLabel4.font = kPingFangRegular(16);
    self.nameLabel4.textColor = rgba(51, 51, 51, 1);
    self.nameLabel4.textAlignment = NSTextAlignmentCenter;
    self.nameLabel4.text = @"头像面";
    
    self.contentLabel4 = [[UILabel alloc]initWithFrame:CGRectMake(0, (self.BJView4.height-60)/2+30, (APPwidth-30)/2, 30)];
    self.contentLabel4.font = kPingFangRegular(12);
    self.contentLabel4.textColor = rgba(153, 153, 153, 1);
    self.contentLabel4.textAlignment = NSTextAlignmentCenter;
    self.contentLabel4.text = @"上传身份证头像面";
    
    self.photoImage4 = [[UIImageView alloc]initWithFrame:CGRectMake((APPwidth-30)/2, 24, (APPwidth-30)/2-30, ((APPwidth-30)/2-30)*88/135)];
    self.photoImage4.userInteractionEnabled = YES;
    //添加虚线边框
    CAShapeLayer*border4 = [CAShapeLayer layer];
    border4.strokeColor=rgba(153, 153, 153, 1).CGColor;
    border4.fillColor= [UIColor clearColor].CGColor;
    border4.path= [UIBezierPath bezierPathWithRoundedRect:self.photoImage4.bounds cornerRadius:0].CGPath;
    border4.frame= self.photoImage4.bounds;
    border4.lineWidth=1.0f;
    border4.lineDashPattern=@[@4,@2];
    [self.photoImage4.layer addSublayer:border4];
    
    [self.BJView4 addSubview:self.nameLabel4];
    [self.BJView4 addSubview:self.contentLabel4];
    [self.BJView4 addSubview:self.photoImage4];
    


    [self.contentView addSubview:HeaderV];
    [self.contentView addSubview:self.BJView1];
    [self.contentView addSubview:self.BJView2];
    [self.contentView addSubview:self.BJView3];
    [self.contentView addSubview:self.BJView4];

    
}


-(void)cellFillWithModel:(CoachsBookInputModel *)model
{
    
    if ([LongHelper isBlankString:model.idCardfacephotourl]) {
        self.photoImage1.image = model.idCardfacephotoimage;
    }
    else{
        [self.photoImage1 sd_setImageWithURL:[NSURL URLWithString:model.idCardfacephotourl] placeholderImage:zhanweiimage];
    }
    
    if ([LongHelper isBlankString:model.idCardbadgephotourl]) {
        self.photoImage2.image = model.idCardbadgephotoimage;
    }
    else{
        [self.photoImage2 sd_setImageWithURL:[NSURL URLWithString:model.idCardbadgephotourl] placeholderImage:zhanweiimage];
    }
    
    
    if ([LongHelper isBlankString:model.driverlicensephotourl]) {
        self.photoImage3.image = model.driverlicensephotoimage;
    }
    else{
        [self.photoImage3 sd_setImageWithURL:[NSURL URLWithString:model.driverlicensephotourl] placeholderImage:zhanweiimage];
    }
    
    
    if ([LongHelper isBlankString:model.avatarphotourl]) {
        self.photoImage4.image = model.avatarphotoimage;
    }
    else{
        [self.photoImage4 sd_setImageWithURL:[NSURL URLWithString:model.avatarphotourl] placeholderImage:zhanweiimage];
    }

}



- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
